<extend name="Layout:ly2"/>

<block name="head">
<script type="text/javascript">
    $(function(){
        $("#btn-submit").click(function(){
            var keyword = $("input[name='keyword']").val();
            var stars = $(".stars").val();

            if (keyword == '') {layer.msg('关键词不能为空');return false;}

            $.get("{:U('Admin/Keyword/keyword_add')}",{'action':'add','keyword':keyword,'stars':stars},function(msg){
                if(msg == 1){
                    layer.msg("添加成功，1秒后自动关闭~~",{ico:1,time:1000},function(){
                        parent.window.location.reload();    //刷新父页面
                    })
                }else if(msg == 2){
                    layer.msg("关键词已存在，1秒后自动关闭~~",{ico:1,time:1000},function(){
                        parent.window.location.reload();    //刷新父页面
                    })
                }else{
                    layer.msg("添加失败，1秒后自动关闭~~",{ico:1,time:1000},function(){
                        parent.window.location.reload();    //刷新父页面
                    })
                }
            })
        })
    })
</script>
</block>

<block name="body">
    <div class="container-fluid">
        <h3 id="title" align="center">添加关键词</h3>
        <div class="padding20">
            <div class="form-horizontal p90">
                <div class="form-group">
                    <label class="col-sm-2 control-label">关键词：</label>
                    <div class="col-sm-8">
                        <input type="text" name="keyword" class="form-control" value="" />
                    </div>
                    <div class="col-sm-2"></div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">热度：</label>
                    <div class="col-sm-8">
                        <select name="stars" class="form-control stars">
                            <option value="0">0</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        </select>
                    </div>
                    <div class="col-sm-2"></div>
                </div>

                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" id="btn-submit" class="btn btn-success">添加</button>&nbsp;&nbsp;&nbsp;&nbsp;
                        <button type="reset" class="btn btn-default">重置</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

</block>